<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<style>
.td_item {
    height:30px; 
    line-height: 30px; 
    width: 100%;   
    vertical-align: middle; 
    margin:0px; 
    padding:0px 0px 0px 0px; 
    overflow: hidden;
    border-top:solid 1px #b7d1e6;
}

.td_item2 {
	height: 30px;
	line-height: 30px;
	width: 100%;
	vertical-align: middle;
	margin: 0px;
	padding: 0px 0px 0px 0px;
	overflow: hidden;
	
}

.checkboxWidth {
	width: 200px;
}

.td_item_span {
	display: block;
	text-align: center;
	width: 71% !important;
}
</style>
<x:parse xml="${param.xmlstr}" var="xmlData" />
<c:set var="grant_code">
	<x:out select="$xmlData/data/proposal/grant_code" />
</c:set>
<c:set var="sub_grant_code">
	<x:out select="$xmlData/data/proposal/sub_grant_code" />
</c:set>
<c:set var="nature_value">
	<x:out
		select="$xmlData/data/organizations/organization[@submit_org='1']/nature_value" />
</c:set>

<c:if test="${grant_code==635}">
	<!-- 635国家基础科学人才培养基金 -->
	<c:set var="Class">class="gray" </c:set>
</c:if>
<div style="margin-bottom: 5px;">
    		<strong>温馨提示：</strong><br/>
    		<security:authorize ifNotGranted="A_DAILU_PROPOSAL">
    		单位财务信息从【单位维护表】中导入，由单位管理员填写，如有疑问请联系单位管理员进行修改。 
    		</security:authorize>
    		<security:authorize ifAnyGranted="A_DAILU_PROPOSAL">
    		单位财务信息从【单位维护表】中导入，如有数据需要调整，请您到【系统管理】->【单位信息维护】功能进行修改 。
    		</security:authorize>
</div>
<div class="t_bar">单位财务情况（单位：万元）</div>
<table width="100%" border="0" cellpadding="0" cellspacing="1"
	id="finances" class="t_css">
	<tr class="t_tr">
		<td align="center" width="20%">指标</td>
		<td align="center" width="27%">大前年度（${year-3 }）年</td>
		<td align="center" width="27%">前年度（${year-2 }）年</td>
		<td align="center" width="26%">上年度（${year-1 }）年</td>
	</tr>
	
	
	
	
	<!-- 企业财务 -->
	<c:set var="finance_items"
		value="&nbsp;&nbsp;主营收入,&nbsp;&nbsp;其中，主营业务收入,&nbsp;&nbsp;主营业务利润,&nbsp;&nbsp;净利润,&nbsp;&nbsp;纳税总额,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;其中，营业税,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;其中，增值税,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;其中，企业所得税,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;其中，个人所得税,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;其中，其他税,&nbsp;&nbsp;年末资产总额,&nbsp;&nbsp;其中，年末固定资产净值,&nbsp;&nbsp;年末负债总额,&nbsp;&nbsp;年末资产负债率（%）,&nbsp;&nbsp;总现金流量净额,&nbsp;&nbsp;经营活动现金流量净额"
		scope="page"></c:set>
	
		<tr class="li_1" id="finance_enterprise">
			<td style="padding: 0px">
			     <c:forEach items="${fn:split(finance_items, ',') }" var="item" varStatus="sta">
					<div class="td_item" 
						<c:if test="${sta.index%2!=0 }">style="background:#f1f1f1;"</c:if>><span style="text-align:left">${item}</span></div>
				</c:forEach>
		    </td>
			<c:set value="1" var="index" scope="page" />
			<x:forEach select="$xmlData/data/organization/finances/finance" var="finance" varStatus="finSta">
				<c:if test="${finSta.index>0 }">
					<c:set var="finance_type"><x:out select="$finance/@type" /></c:set>
					<c:if test='${finance_type=="企业财务" }'>
						<c:if test="${index==1||index==2||index==4 }">
							<td style="border-left: 1px solid #FFF;" id="td_item_${index}_0"><c:choose>
									<c:when test="${index==1 }">
										<input type="hidden"
											name="organization/finances/finance[${index }]@year"
											value="${year-3 }" />
									</c:when>
									<c:when test="${index==2 }">
										<input type="hidden"
											name="organization/finances/finance[${index }]@year"
											value="${year-2 }" />
									</c:when>
									<c:when test="${index==4 }">
										<input type="hidden"
											name="organization/finances/finance[${index }]@year"
											value="${year-1 }" />
									</c:when>
								</c:choose> <input type="hidden"
								name="organization/finances/finance[${index }]@sequence_no"
								value="${index+1 }" /> <input type="hidden"
								name="organization/finances/finance[${index }]@type"
								value="企业财务" />
								<div class="td_item" id="td_item_${index}_1">
								<span 
										name="organization/finances/finance[${index }]/income"><x:out
											select="$finance/income" /></span>
								</div>								
								
								<div class="td_item" id="td_item_${index}_2">
									<span 
										name="organization/finances/finance[${index }]/income_main"><x:out
											select="$finance/income_main" /></span>
								</div>
								
								<div class="td_item" id="td_item_${index}_3">
									<span 
										name="organization/finances/finance[${index }]/proft_main"><x:out
											select="$finance/proft_main" /></span>
								</div>
								
								
								
								<div class="td_item" id="td_item_${index}_4">
									<span 
										name="organization/finances/finance[${index }]/proft"><x:out
											select="$finance/proft" /></span>
								</div>
								
								<div class="td_item" id="td_item_${index}_5">
									<span name="organization/finances/finance[${index }]/fax"><x:out
											select="$finance/fax" /></span>
								</div>
								
								<div class="td_item" id="td_item_${index}_6">
									<span i
										name="organization/finances/finance[${index }]/fax_bussiness"><x:out
											select="$finance/fax_bussiness" /></span>
								</div>
								
								<div class="td_item" id="td_item_${index}_16">
									<span i
										name="organization/finances/finance[${index }]/fax_added"><x:out
											select="$finance/fax_added" /></span>
								</div>
								
								<div class="td_item" id="td_item_${index}_7">
									<span  
										name="organization/finances/finance[${index }]/fax_income"><x:out
											select="$finance/fax_income" /></span>
								</div>
								<div class="td_item" id="td_item_${index}_8">
									<span 
										name="organization/finances/finance[${index }]/fax_personal"><x:out
											select="$finance/fax_personal" /></span>
								</div>
								<div class="td_item" id="td_item_${index}_9">
									<span 
										name="organization/finances/finance[${index }]/fax_other"><x:out
											select="$finance/fax_other" /></span>
								</div>
								

								<div class="td_item" id="td_item_${index}_10">
									<span  id="finance_930_${index }" 
										name="organization/finances/finance[${index }]/assets"><x:out
											select="$finance/assets" /></span>
								</div>
								<div class="td_item" id="td_item_${index}_11">
									<span 
										name="organization/finances/finance[${index }]/assets_fixed"><x:out
											select="$finance/assets_fixed" /></span>
								</div>
								<div class="td_item" id="td_item_${index}_12">
									<span id="finance_932_${index }" 
										name="organization/finances/finance[${index }]/liabilities"><x:out
											select="$finance/liabilities" /></span>
								</div>
								<div class="td_item" id="td_item_${index}_13">
									<span id="finance_935_${index }" 
										name="organization/finances/finance[${index }]/liabilities_pre"><x:out
											select="$finance/liabilities_pre" /></span>
								</div>
								
								
								<div class="td_item" id="td_item_${index}_14">
									<span 
										name="organization/finances/finance[${index }]/caseflow"><x:out
											select="$finance/caseflow" /></span>
								</div>
								<div class="td_item" id="td_item_${index}_15">
									<span 
										name="organization/finances/finance[${index }]/caseflow_active"><x:out
											select="$finance/caseflow_active" /></span>
								</div>
								
								
								</td>
						</c:if>

						<c:set value="${index+1 }" var="index" scope="page" />
					</c:if>
				</c:if>
			</x:forEach>
		</tr>
</table>

<div class="t_bar"><span class="color_red">*</span>主要业务情况</div>	
<table id="mainBusinessInfos" cellpadding="0" class="table01" width="100%"
	border="0" cellpadding="0" style="*border-bottom: #a1c0dc 1px solid;">
	<thead>
		<tr style="border: 1px solid #B7D1E6">
			<th class="TblHead" align="center" width="5%">选择</th>
			<th class="TblHead" align="center" width="5%">序号</th>
			<th class="TblHead" align="center" width="35%">主要经营业务名称</th>
			<th class="TblHead" align="center" width="35%">占企业营业收入总额比例（%）</th>
			<th class="TblHead" align="center" width="20%">备注</th>
			
		</tr>
	</thead>
	<tbody id="tab">
		<tr style="display: none">
			<td align="center"><input type="radio" class="radiobutton" name="selBusinessInfos">
			</td>
			<td align="center"><span name="businessinfos|businessinfo[0]@seq_no">[index]</span>
			</td>
			<td style="text-align: center;"><input type="text" style="width:80%"
				name="businessinfos|businessinfo[0]|business_name" class="input_text required"
				maxlength=100 label="主要经营业务名称" value="" />
			</td>
			<td style="text-align: center;"><input type="text" style="width:80%;text-align: right;"
				name="businessinfos|businessinfo[0]|income_pre" class="input_text required"
				onfocus="InitInput.setNumber(this,7,2,2)"
				maxlength=100 label="占企业营业收入总额比例" value="" />
			</td>
			<td style="text-align: center;"><input type="text" style="width:80%"
				name="businessinfos|businessinfo[0]|remark" class="input_text required"
				maxlength=100 label="备注" value="" />
			</td>
		</tr>


		<c:set value="0" var="index" scope="page" />
		<x:forEach select="$xmlData/data/businessinfos/businessinfo" var="businessinfo">

			<c:choose>
				<c:when test="${index<10}">
					<c:set value="0" var="flag" scope="page" />
				</c:when>
				<c:otherwise>
					<c:set value="" var="flag" scope="page" />
				</c:otherwise>
			</c:choose>
			<tr>
				<td align="center"><input type="radio" class="radiobutton" name="selBusinessInfos">
				</td>
				<td align="center"><span
					name="businessinfos/businessinfo[${flag}${index}]@seq_no">${index+1}</span></td>
				<td style="text-align: center;"><input type="text" style="width:80%"
					name="businessinfos/businessinfo[${flag}${index}]/business_name"
					class="input_text required" maxlength=100 label="主要经营业务名称"
					value="<x:out select="$businessinfo/business_name" />" />
				</td>
			<td style="text-align: center;"><input type="text" style="width:80%;text-align: right;"
					name="businessinfos/businessinfo[${flag}${index}]/income_pre"
					onfocus="InitInput.setNumber(this,7,2,2)"
					class="input_text required" maxlength=100 label="占企业营业收入总额比例"
					value="<x:out select="$businessinfo/income_pre" />" />
				</td>
				<td style="text-align: center;"><input type="text" style="width:80%"
					name="businessinfos/businessinfo[${flag}${index}]/remark"
					class="input_text required" maxlength=100 label="备注"
					value="<x:out select="$businessinfo/remark" />" />
				</td>
			</tr>
			<c:set value="${index+1}" var="index" scope="page" />
		</x:forEach>
		
	</tbody>
</table>
<table width="98%" align="center" border="0">
					<tr style="border: 0"><td style="border: 0"><input class="button" name="cmdAddbefore" type=button
			value="添加"
			onclick="if(checkTabLimit('mainBusinessInfos',99,'最多只能添加99条主要业务信息')){addNewRow('mainBusinessInfos');try{top.resizeFrame();}catch(e){};}">
			<input class="button" name="cmdMovePrev"
			type=button value="上移"
			onclick="movePrev('mainBusinessInfos','selBusinessInfos')"> <input
			class="button" name="cmdMoveNext" type=button value="下移"
			onclick="moveNext('mainBusinessInfos','selBusinessInfos')"> <input
			class="button" name="cmddel" type=button value="删除"
			onclick="deleteSelectedRow('mainBusinessInfos','主要业务情况')"></td>
	</tr>
</table>
	
<script type="text/javascript">
	$(function() {
		$("#finance_935_1").text(thousandsNumber(formatVal($("#finance_932_1").text().replace(/,/g,'')*100/$("#finance_930_1").text().replace(/,/g,''))));
		$("#finance_935_2").text(thousandsNumber(formatVal($("#finance_932_2").text().replace(/,/g,'')*100/$("#finance_930_2").text().replace(/,/g,''))));
		$("#finance_935_4").text(thousandsNumber(formatVal($("#finance_932_4").text().replace(/,/g,'')*100/$("#finance_930_4").text().replace(/,/g,''))));

		$("#finance_enterprise").children("td:not(:first)").each(function(){
			setFinanceStyle($(this));
		});
		
		//$("div[id^='td_item_1_']").hide();
		//$("div[id^='td_item_2_']").hide();
		//$("td[id^='td_item_1_']").hide();
		//$("td[id^='td_item_2_']").hide();
		//$("div[id$=td_item_1_]").hide();
		
		//$("#income_main_zc_4").addClass("required");
		
		
	});
	
	
	
	/*
	 * 设置财务样式
	 */
	 function setFinanceStyle(obj) {
		obj.css("padding", "0").children("div:odd").css("background", "#f1f1f1");
		obj.find("input").css("width", 120).css("margin-top", "3px").css("height", "18px");
		obj.find("span").attr("style", "width: 95%; text-align: center; display: block;");
	 }
	 /**
	  * 将值以千分位显示
	  * @param value 数值
	  */
	 function thousandsNumber(value) {
	 	if (value == null || value == undefined || value == "") {
	 		return "";
	 	}
	 	var negative = '';
	 	var intVal = value.split(".")[0];
	 	var j = intVal.length;
	 	if(intVal.charAt(0) == '-'){
	 		negative = '-';
	 		intVal = intVal.substr(1, j);
	 	}
	 	j = intVal.length;
	 	for(var i=j-3; i>0; i=i-3){
	 		intVal = intVal.substr(0, i) + "," + intVal.substr(i, j);
	 	}
	 	if(value.split(".")[1] != null){
	 		return (negative + intVal + '.' + value.split(".")[1]);
	 	} else{
	 		return (negative + intVal);
	 	}
	 }
</script>

